<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>多边形的绘制</title>
    <script type="text/javascript"
        src="https://webapi.amap.com/maps?v=1.4.14&key=cee005f5ef04df4d58c24345425ec3ff"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body,
        #container {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <div id="container"></div>
    <script>
        var map = new AMap.Map('container', {
            center: [116.397637, 39.900001],
            zoom: 14
        });
        var path = [
            [116.403322, 39.920255],
            [116.410703, 39.897555],
            [116.402292, 39.892353],
            [116.389846, 39.891365]
        ]

        var polygon = new AMap.Polygon({
            path: path,
            strokeColor: "#FF33FF",
            strokeWeight: 6,
            strokeOpacity: 0.2,
            fillOpacity: 0.4,
            fillColor: '#1791fc',
            zIndex: 50,
        })

        map.add(polygon)
        // 缩放地图到合适的视野级别
        map.setFitView([polygon])
    </script>
</body>

</html>